package com.practice.utils;


import com.github.pagehelper.PageHelper;
import org.springframework.util.ObjectUtils;

import java.util.Map;

/**
 * 设置分页查询参数
 */
public class Query {

    private final String PAGE = "currPage";
    private final String LIMIT = "pageSize";

    public void setStartPage(Map<String, Object> params) {
        int currPage = ObjectUtils.isEmpty(params.get(PAGE)) ? 1 : (int) params.get(PAGE);
        int pageSize = ObjectUtils.isEmpty(params.get(LIMIT)) ? 10 : (int) params.get(LIMIT);

        //通过插件设置分页
        PageHelper.startPage(currPage, pageSize);
    }

}
